package com.iris.lock;

/**
 * @author : Iris.Xiao
 * @date : 2018/03/21 14:33
 * @description :
 */
public class DeadLock implements Runnable {
    private LockObject lockObject;
    public DeadLock(LockObject lockObject){
        this.lockObject = lockObject;
    }

    /**
     * When an object implementing interface <code>Runnable</code> is used
     * to create a thread, starting the thread causes the object's
     * <code>run</code> method to be called in that separately executing
     * thread.
     * <p>
     * The general contract of the method <code>run</code> is that it may
     * take any action whatsoever.
     *
     * @see Thread#run()
     */
    @Override
    public void run() {
        synchronized (lockObject){

            System.out.println(this.toString()+"====start");
            try {
                Thread.sleep(2000L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
//            sonObject = lockObject.getSonObject();
            LockObject sonObject = lockObject.getSonObject();
            System.out.println(this.toString()+"====end");
        }
    }
}
